<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>

<body>
<?php
/* 用户登陆处理页 */
require_once("../conn/conn_db.php");   //包含数据库连接文件
if( $_POST["txt_username"]!= "" && $_POST["txt_pwd"]!= "" )
{
    $name = $_POST["txt_username"];   //获取提交的用户名
    $pwd = $_POST["txt_pwd"];         //获取提交的密码
    $sql = "select * from user_info where u_name = '$name' and u_pwd = '$pwd' and u_status='1'"; //查询语句
    $result = $conn->query($sql);      //执行SQL语句
    echo $result->num_rows;
    if ($result->num_rows > 0)  //查看返回的查询结果行数
    {
        session_start();                //登陆成功，设置SESSION值
        $_SESSION['user'] = $_POST['txt_username'];
        echo "<script> self.location='../main.php';</script>";
    }
    else
    {
        echo "<script>alert('您的账号信息有误，请联系管理员后重试！');self.location='../login.php'</script>";
    }
}
else
{
    echo "<script>alert('请输入用户名和密码！');self.location='../login.php'</script>";
}
?>	
</body>
</html>